﻿using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public enum ButtonSoundType
{
    Normal = 0,
    MainMenu,
    Dakaibaoxiang,
    Fasongxiaoxi,
    Goumaidaoju,
    Kejishengji,
}

/// <summary>
/// 按钮点击音效
/// </summary>
[DisallowMultipleComponent]
[RequireComponent(typeof(Button))]
public class ButtonSound : MonoBehaviour
{
    public static Dictionary<ButtonSoundType, int> TypeToId = new Dictionary<ButtonSoundType, int>()
    {
        {ButtonSoundType.Normal, Constant.Music.Click},
    };

    [SerializeField]
    private ButtonSoundType m_Type = ButtonSoundType.Normal;

    private void Awake()
    {
        //if (GameEntry.Sound == null)
        //    return;
        Button btn = GetComponent<Button>();
        btn.onClick.AddListener(OnClick);
    }

    void OnClick()
    {
        if (TypeToId.TryGetValue(m_Type, out int id))
        {
            //GameEntry.Sound.PlayUISound(id);
        }
    }

    public void ChangeType()
    {
        m_Type = ButtonSoundType.Normal;
    }
}